package com.gpvip.study.simplefactory;

/**
 * @Author：xuchy
 * @Date：2020/2/24
 */
public class PayFactory {

    private static final PayFactory INSTANCE;

    static {
        INSTANCE = new PayFactory();
    }

    private PayFactory() {

    }

    public static PayFactory getInstance() {
        return INSTANCE;
    }

    public IPay createPay(Class<? extends IPay> clazz) {
        try {
            if (clazz != null) {
                return clazz.newInstance();
            }
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        //默认银联支付
        return new UnionPay();
    }
}
